﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pyramid
{
    class DetailandColorBlend:Blend
    {
      
       
        public override void Init(int MRMethod, int ExtensionMethod)
        {
          
            int l, level;
  
            double[] r = new double[CoarseImage.Depth];

            init_general(MRMethod, ExtensionMethod);

        

            //build the pyramid itself
            ImagePyramid = new List<GImage>();
            ImagePyramid.Add(CoarseImage);
            level = 1;
            ImageWithDetail d = new ImageWithDetail();
            d.TheImage = new GImage(CoarseImage);
            d.TheDetails = new List<GImage>();
            for (l = coarse_level + 1; l <= fine_level - 1; l++)
            {
                double alpha = (1.0) * (l - coarse_level) / (fine_level - coarse_level);
                //d.TheImage = (1 - alpha) * d.TheImage + alpha * G[level-1].TheImage;
                d.TheDetails = Fine_Image_Pyramid[level - 1].TheDetails;
                if (MR.AmplifyDetails && MR.Amp_Factor==0) MR.Amp_Factor = alpha;
                d = MR.UpSample(d);
                d.TheImage = (1 - alpha) * d.TheImage + alpha * Fine_Image_Pyramid[level].TheImage;
                level++;
                GImage nextimage = new GImage(d.TheImage);
                ImagePyramid.Add(nextimage);
            }
            ImagePyramid.Add(FineImage);

        }
      
    }
}
